package com.heima.gouzaofangfa;

import java.lang.reflect.Constructor;

public class ConstructDemo04 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException {
        //创建类对象
        Class aClass = Class.forName("com.heima.gouzaofangfa.Student");
        //返回所有公共的constructors对象
        Constructor[] constructors = aClass.getConstructors();
        for (Constructor con : constructors) {
            System.out.println(con);
        }
        //返回所有公共的和私有的cdeclaredAnnotations对象
        Constructor[] declaredConstructors = aClass.getDeclaredConstructors();
        for (Constructor dec : declaredConstructors) {
            System.out.println(dec);
        }
        ///返回单个指定的公共的constructor对象
        Constructor constructor = aClass.getConstructor(String.class,int.class);
        System.out.println(constructor);
        //返回单个指定的公共的和私有的cdeclaredAnnotations对象
        Constructor declaredConstructor = aClass.getDeclaredConstructor(String.class, int.class);
        System.out.println(declaredConstructor);
    }
}
